#include <iostream>

const int QueueSize = 10;
class ArrayQueue
{
public:
    ArrayQueue():front(0),rear(0){}
    //入队列
    // void Push(const int & element)
    // {
    //     if(rear == QueueSize)
    //     {
    //         std::cout<<"队列满"<<std::endl;
    //         return ;
    //     }
    //     a[rear++] = element;
    // }
    void Push(const int & element)
    {
        if((rear + 1) % QueueSize == front)
        {
            std::cout<<"队列满"<<std::endl;
            return;
        }
        a[rear++] = element;
        rear %= QueueSize;
    }

    //出队列
    void Pop()
    {
        if(front == rear)
        {
            std::cout<<"队列空"<<std::endl;
            return ;
        }
        front++;
        front %= QueueSize;
    }

    int *GetFront()  //取队头元素
    {
        if(front == rear)
        {
            std::cout<<"队列空"<<std::endl;
            return nullptr;
        }
        return &a[front];
    }

    bool IsEmpty()  //判断队列是否为空
    {
        return front == rear;
    }

private:
    int a[QueueSize];
    int front;  //队头指针
    int rear;   //队尾指针
};


int main()
{
    ArrayQueue q;
    for(int i = 0; i < 10; i++)
    {
        q.Push(i + 1);
    }

    while(q.IsEmpty() == false)
    {
        std::cout<<*q.GetFront()<<" ";
        q.Pop();
    }
    std::cout<<std::endl;
    return 0;
}